package com.zhouheng.springbootconverter.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import javax.servlet.http.HttpSession;

/**
 * Swagger接口文档配置类
 *
 * @author zhongyong
 * @date 20181119
 * @since v1.0
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Bean
    public Docket sysApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo("Converter测试", "converter", "1.0"))
                .groupName("1.转换测试")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.zhouheng.springbootconverter.controller"))
                .paths(PathSelectors.any())
                .build()
                //这里用不到，排除入参在ui上展示的
                .ignoredParameterTypes(HttpSession.class);
    }


    private ApiInfo apiInfo(String name, String description, String version) {
        ApiInfo apiInfo = new ApiInfoBuilder().title("websys-" + name).description(description).version(version).build();
        return apiInfo;
    }


}
